<template>
  <div class="weather">
    <el-popover
    width='400'
      placement="bottom-start"
      trigger="hover">
      <!-- 展开预测内容 -->
      <div class="forecast">
        <div>今天{{weatherInfo[0].date}}</div>
          <div class="today">
            <div class="iconBox"><i :class="weatherInfo[0].icon"></i></div>
            <div class="info">
              <div class="city">{{weatherInfo[0].city}}</div>
              <div>{{weatherInfo[0].type}}</div>
              <div>{{weatherInfo[0].low.split(' ')[1]}}~{{weatherInfo[0].high.split(' ')[1]}}</div>
            </div>
          </div>
          <div class="day" v-for="(item,index) in weatherInfo" :key="index">
            <div class="dayBox" v-if="index!==0">
              <div>{{item.date}}</div>
              <div><i :class="item.icon"></i></div>
              <div>{{item.type}}</div>
              <div>{{item.low.split(' ')[1]}}~{{item.high.split(' ')[1]}}</div>
            </div>
          </div>
      </div>
      <!-- 外部显示 -->
      <div class="weatherBox" slot="reference">
        <!-- 晴天 -->
        {{weatherInfo[0].city}}
        <span><i :class="weatherInfo[0].icon"></i></span>
        <span>{{weatherInfo[0].type}}</span>
        <span>{{weatherInfo[0].low.split(' ')[1]}}~{{weatherInfo[0].high.split(' ')[1]}}</span>
      </div>
    </el-popover>

  </div>
</template>

<script>
export default {
  name: "weather",
  components: {},
  props: {
    weatherInfo:{
      type:Array,
      default: () => {
        return []
      }
    }
  },
  data () {
    return {

    }
  },
  computed: {

  },
  watch: {},
  created () {},
  mounted () {
  },
  methods: {

  }
}
</script>

<style scoped lang="scss">
.weather{
  height: 100%;

}
.forecast{
    .today{
      padding: 1rem;
      border-bottom: 1px solid #ccc;
      display: flex;
      justify-content: space-around;
      .info div{
        line-height:1.6rem;
      }
      .city{
        font-weight:600
      }
    }
    .iconBox{
      padding: 1.2rem;
      background-color: #37c1ff;
      border-radius: .2rem
    }
    .day{
      background-color: #37c0ff5d;
      margin: .5rem 0;
      padding: 0 .5rem;
      .dayBox{
        display: flex;
        justify-content: space-between;
        align-items: center;
        div{
          padding: 0 .3rem;
        }
      }
    }
  }
.weatherBox{
  cursor: pointer;
  font-size: 1rem;
  color: #ffffff;
  display: flex;
  align-items: center;
  height: 100%;
  justify-content: center;
  span{
    margin-left: 1rem
  }
}
  .iconfont{
    font-size: 2rem;
    color: #ffffff;

  }
</style>
